// pages/user/share/share.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        qrcode: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.onPullDownRefresh();
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {
        wx.http.get('api/user.index/get_qrcode', {}, {
            showLoading: true
        }).then((res) => {
            console.log(res);
            this.setData({
                qrcode: res.data.data.qrcode
            });
        });
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {
        return {
            image: this.data.qrcode,
            path: '/pages/index/index'
        };
    },

    onPreviewTap: function(e) {
        wx.previewImage({
            urls: [this.data.qrcode],
            current: this.data.qrcode
        })
    },
})